﻿using FutureApp.Roles;
using FutureApp.Roles.Dto;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace FutureApp.Web.Controllers
{
    public class RolesController : FutureAppControllerBase
    {
        public IRoleAppService RoleAppService { get; set; }

        public ActionResult List()
        {
            var output = this.RoleAppService.GetRoles();
            return this.View(output);
        }

        public ActionResult Add()
        {
            return this.View();
        }

        public async Task<ActionResult> Edit(int id)
        {
            var role = await this.RoleAppService.GetRoleById(id);
            return this.View(role);
        }

        public async Task<ActionResult> Authorize(int id)
        {
            var input = new GetRoleUsersInput { RoleId = id };
            var output = await this.RoleAppService.GetRoleUsers(input);
            return this.View(output);
        }

        public async Task<ActionResult> Assign(int id)
        {
            var input = new GetRolePermissionsInput { RoleId = id };
            var output = await this.RoleAppService.GetRolePermissions(input);
            return this.View(output);
        }
    }
}
